package com.sky.controller.admin;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Slf4j
public class ShopController {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable String status) {
        log.info("营业状态:{}",status.equals("1")?"营业中":"打样中");
        stringRedisTemplate.opsForValue().set("SHOP:STATUS", status);
        return Result.success();
    }

    @GetMapping("/status")
    public Result getStatus() {
        String status = stringRedisTemplate.opsForValue().get("SHOP:STATUS");
        return Result.success(Integer.valueOf(status));
    }
}
